package com.wcar.vipmanagement.controller;

import com.wcar.common.entity.Car;
import com.wcar.common.entity.FrontUser;
import com.wcar.common.vo.Result;
import com.wcar.vipmanagement.dao.CarStoreMapper;
import com.wcar.vipmanagement.service.CarService;
import com.wcar.vipmanagement.service.CarStoreService;
import com.wcar.vipmanagement.service.impl.FrontUserServiceImpl;
import com.wcar.vipmanagement.service.impl.OrderServerImpl;
import com.wcar.vipmanagement.service.impl.UserBalanceLogServicceImpl;
import com.wcar.vipmanagement.service.impl.UserIntegralLogServiceImpl;
import com.wcar.vipmanagement.vo.ChongzhiVo;
import com.wcar.vipmanagement.vo.allVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @program: four-wcar-idea
 * @description:
 * @author: 张云龙
 * @create: 2024-05-31 16:09
 **/
@RestController
@RequestMapping("/car")
public class CarController {

	@Autowired
	private FrontUserServiceImpl frontUserService;
	@Autowired
	private OrderServerImpl orderServer;
	@Autowired
	private UserBalanceLogServicceImpl userBalanceLog;
	@Autowired
	private UserIntegralLogServiceImpl userIntegralLogService;
	@Resource
	private CarService carService;
	@Resource
	private CarStoreService carStoreService;

	@GetMapping("/api/getUserInfo")
	public Result<FrontUser> getUserInfo() {
		return frontUserService.getallByid();
	}

	@PostMapping("/api/getRechargeNative")
	public Result<Map<String, String>> getRechargeNative(@RequestBody ChongzhiVo chongzhiVo) {
		return orderServer.creataNate(chongzhiVo);
	}

	@PostMapping("/api/queryPayStatus/{detailNo}")
	public Result queryPayStatus(@PathVariable String detailNo) {
		return orderServer.queryPayStutus(detailNo);
	}

	@PostMapping("/api/selectBalanceByUserId")
	public Result selectBalanceByUserId(@RequestParam("id") String id) {
		return userBalanceLog.selectBalanceByUserId(id);
	}
	@GetMapping("api/selectBalanceDetail")
	public  Result<allVo>  selectBalanceDetail(@RequestParam("userId") String userId) {
		System.out.println(userId);
		return userBalanceLog.selectBalanceDetail(userId);
	}
	@PostMapping("/api/selectIntegralByUserId")
	public Result selectIntegralByUserId(@RequestParam("id") String id) {
		return userIntegralLogService.selectIntegralByUserId(id);
	}
	@GetMapping("/api/carBind")
	public Result<List<Car>> selectcar(){
		return carService.selectCar();
	}
	@DeleteMapping("/api/deleteCarNo")
	public Result<Integer> deleteCarStore(String carNo){
		return carStoreService.deleteCarStore(carNo);
	}
	@GetMapping("/api/findCarId")
	public Result<Car> fondCarId(String carNo){
		return carService.findCar(carNo);
	}
}
